<template>
	<view class="">
		<form @submit="formSubmit" action="">
			<view class="" style="display: flex;align-items: center;justify-content: center;width: 750upx;margin-top: 300upx;">
				<view class="">
					账号：
				</view>
				<input class="uni-input" style="background-color: aliceblue;" name="phone" placeholder="请输入账号" />
			</view>
			<view class="" style="display: flex;align-items: center;justify-content: center;width: 750upx;margin-top: 30upx;">
				<view class="">
					密码：
				</view>
				<input class="uni-input" style="background-color: aliceblue;" name="psd" placeholder="请输入密码" />
			</view>
			<button style="display: flex;align-items: center;justify-content: center;width: 750upx;margin-top: 50upx;" form-type="submit">登录</button>
			<button style="display: flex;align-items: center;justify-content: center;width: 750upx;margin-top: 20upx;" @click="navIndex">取消</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		onLoad() {
	
		},
		onShow() {
			
		},
		
		methods: {
			formSubmit: async function(e){
				// console.log(123,e.detail.value.phone)
				// console.log(123,e.detail.value.psd)
				if(!e.detail.value.phone){
					uni.showToast({
						duration:1000,
						title:"账号不能为空！",
						icon:"none"
					})
				}else if(!e.detail.value.psd){
					uni.showToast({
						duration:1000,
						title:"密码不能为空！",
						icon:"none"
					})
				}else{
					
					// const system = await this.$ajax.system({
					// 	password:"123456",
					// 	// phone:"13531880826"
					// 	phone:"18890268412"
					// })
					// uni.setStorageSync('token', system.data.data.token);
					// console.log("system:",system)
					
					const miniLoginByPd = await this.$ajax.miniLoginByPd({
						password:e.detail.value.psd,
						// phone:"13531880826"
						phone:e.detail.value.phone
					})
					console.log(miniLoginByPd)
					if(miniLoginByPd.data.code==200){
						uni.setStorageSync('token', miniLoginByPd.data.data.token);
						uni.navigateBack({
							delta:1
						})
					}else{
						uni.showToast({
							title:miniLoginByPd.data.data,
							icon:"none",
							duration:1000
							
						})
					}
				}
				
				// system.data.data.token
			},
			navIndex(){
				uni.switchTab({
					url:"/pages/home/index"
				})
			}
		},
	}
</script>

<style>
</style>